#include <cstdlib>
#include <iostream>
#include "chessboard.h"

using std::cout;
using std::cerr;
using std::cin;
using std::endl;

/// Constructure function of Chessboard
///
/// Initialising chessboard to be empty without any chess pieces.
Chessboard::Chessboard(){
	for(auto &i : m_grids){
		for(auto &j : i){
			j = nothing;
		}
	}
}

/// Drawing chessboard to terminal
void Chessboard::show(){
	system("clear");
	for(auto beg = m_grids.front().begin(); beg != m_grids.front().end(); beg++){
		switch (*beg){
			case black:
				cout << " X ";
				break;
			case white:
				cout << " O ";
				break;
			case nothing:
				cout << "   ";
				break;
			default:
				break;
		}
		if(beg != m_grids.front().end()-1){
			cout << "——";
		}
	}
	cout << "\n";
	for(int i = 1; i < chessboardSize; i++){
		for(int j = 0; j < chessboardSize-1; j++){
			cout << " | " << "  ";
		}
		cout << " | " << "\n";
		for(int j = 0; j < chessboardSize; j++){
			switch (m_grids[i][j]){
				case black:
					cout << " X ";
					break;
				case white:
					cout << " O ";
					break;
				case nothing:
					cout << "   ";
					break;
				default:
					break;
			}
			if(j != chessboardSize-1)
				cout << "——";
		}
		cout << "\n";
	}
}
